﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WowParserLib.Events
{
    public abstract class Event
    {
        private Affiliation _affiliation;

        public Affiliation Affiliation
        {
            get { return _affiliation; }
            set { _affiliation = value; }
        }
        private UnitType _unitType;

        public UnitType UnitType
        {
            get { return _unitType; }
            set { _unitType = value; }
        }
        private Ownership _ownership;

        public Ownership Ownership
        {
            get { return _ownership; }
            set { _ownership = value; }
        }
        private Reaction _reaction;

        public Reaction Reaction
        {
            get { return _reaction; }
            set { _reaction = value; }
        }

        private int _id;

        public int Id
        {
            get { return _id; }
        }

        private DateTime _timestamp;

        protected Actor _target;

        public Actor Target
        {
            get { return _target; }
        }

        protected Actor _source;

        public Actor Source
        {
            get { return _source; }
        }

        public Event() { }

        /// <summary>
        /// Replace with parameter injection
        /// </summary>
        /// <param name="id"></param>
        /// <param name="timestamp"></param>
        /// <param name="source"></param>
        /// <param name="target"></param>
        /// <param name="args"></param>
        public virtual void Initialize(int id, DateTime timestamp, Actor source, Actor target, params EventArguments[] args) 
        {
            _id = id;
            _timestamp = timestamp;
            _target = target;
            _source = source;
            initialize(args);
        }

        protected abstract void initialize(params EventArguments[] args);

        public DateTime Timestamp
        {
            get { return _timestamp; }
        }

        public override string ToString()
        {
            return string.Format("[{0}] {1} ({2}) {3}:{4}:{5}:{6} {7} => {8}", Id, Timestamp, GetType().Name, 
                Affiliation.ToString(), Reaction.ToString(), Ownership.ToString(), UnitType.ToString(),
                Source.Name, Target.Name);
        }
    }
}
